var path = require('path');
var Webpack = require('webpack');
var PurifyCss = require('purifycss-webpack');
var glob = require('glob-all');
var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
module.exports = {
    entry: {
        app: './src/app.js'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: './dist/',
        filename: '[name].bundle.js',
        chunkFilename: '[name].bundle.js'
    },
    module: {
        rules: [{

            test: /\.less$/,
            use:ExtractTextWebpackPlugin.extract({
                fallback:{
                    loader:'style-loader',
                    options:{
                        singleton:true,
                    }
                },
                use:[
                    {
                        loader:'css-loader',
                        options:{
                            modules:true
                        }
                    },
                    {
                        loader: 'postcss-loader',
                        options: {
                            ident: 'postcss',
                            plugins: [
                                // require('autoprefixer')(),
                                require('postcss-cssnext')()
                            ]
                        }
                    },{
                        loader:'less-loader'
                    }
                ]
            })
        }]
    },
    plugins: [
        new ExtractTextWebpackPlugin({
            filename: '[name].min.css',
            allChunks: false,
        }),
        // new PurifyCss({
        //     paths: glob.sync([
        //         path.join(__dirname, './*.html'),
        //         path.join(__dirname, './src/*.js'),
        //     ])
        // }),
        new Webpack.optimize.UglifyJsPlugin()
    ]
}